package cn.sciento.starter.social.wechat.enterprise.connection;

import cn.sciento.starter.social.core.common.api.SocialApi;
import cn.sciento.starter.social.core.common.connect.SocialApiAdapter;
import cn.sciento.starter.social.core.common.connect.SocialConnectionFactory;
import cn.sciento.starter.social.core.common.connect.SocialServiceProvider;
import cn.sciento.starter.social.core.provider.Provider;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionData;
import org.springframework.social.connect.support.OAuth2Connection;
import org.springframework.social.oauth2.OAuth2ServiceProvider;

public class WechatEnterpriseConnectionFactory extends SocialConnectionFactory {
  public WechatEnterpriseConnectionFactory(Provider provider, SocialServiceProvider serviceProvider, SocialApiAdapter apiAdapter) {
    super(provider, serviceProvider, apiAdapter);
  }
  
  public Connection<SocialApi> createConnection(ConnectionData data) {
    return (Connection<SocialApi>)new OAuth2Connection(data, (OAuth2ServiceProvider)getServiceProvider(), (ApiAdapter)new WechatEnterpriseApiAdapter(data.getProviderUserId()));
  }
}
